Disc Golf Disc Classifier
Deep Learning Image Recognition App using FastAI
Live App is running at https://udisc.mattlichti.com/
All the data was submitted through the Udisc Android & iPhone apps https://udisc.com/
The code is based on lessons 1 & 2 of fastai course 3 https://course.fast.ai/
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from fastai.vision import *
from fastai.metrics import error_rate
import urllib.request as req
import pandas as pd
import os
import numpy as np
Step 1: Cleaning the Data and loading it into the fastai ImageDataBunch class
df = pd.read_csv('transformed_97_discs.csv', index_col=0)
df = df.loc[df.downloaded]
df = df.loc[df['size']>=25000]
df.shape
np.random.seed(42)
df = df[df['discName'].isin(['Leopard', 'Buzzz', 'Firebird'])]
df = df.sample(3000)
df.groupby('discName').count()
df.index = df.path
df = df.loc[:, ['disc_label']]
df.to_csv('disc_images/labels.csv')
np.random.seed(42)
path = Path('/home/jupyter/disc_classifier/disc_images')
data = ImageDataBunch.from_csv(path, valid_pct=.1,
ds_tfms=get_transforms(do_flip=False), size=224, num_workers=4).normalize(imagenet_stats)
data.classes, len(data.train_ds), len(data.valid_ds)
data.show_batch()
Step 2: Training the Convolutional Neural Net. We use a 50 layer ResNet that has been pretrained on ImageNet. https://en.wikipedia.org/wiki/Residual_neural_network
learn = cnn_learner(data, models.resnet50, metrics=error_rate)
learn.lr_find()
learn.recorder.plot()
learn.fit_one_cycle(4, max_lr=3*1e-3)